package com.smile.http;
import com.smile.data.dto.StaffQueryDto
import com.smile.data.entity.StaffEntity
import com.smile.response.ResultEmpty
import com.smile.response.ResultPage
import com.smile.service.StaffService
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/staffs")
@Api("员工")
 class StaffController {
    @Autowired
   lateinit var service: StaffService;

    @GetMapping
    @ApiOperation("分页查询")
    fun query(dto: StaffQueryDto) : ResultPage<StaffEntity> {
        return  service.query(dto);
    }
    @PostMapping
    @ApiOperation("新增")
    fun create(@RequestBody dto: StaffEntity) : ResultEmpty {
        return service.create(dto);
    }
    @PutMapping("/{id}")
    @ApiOperation("修改")
    fun update(@PathVariable id: String ,@RequestBody dto: StaffEntity) : ResultEmpty{
        return service.update(id,dto);
    }
    @PostMapping("/{id}")
    @ApiOperation("删除")
    fun remove(@PathVariable id: String) : ResultEmpty{
        return service.remove(id);
    }

}
